<!--
* description: 内部领用单审核-查看明细
-->
<template>
  <section class="editBigAreaInfo">
    <el-dialog
      v-dialogDrag
      :close-on-click-modal="false"
      title="领用备件明细"
      :append-to-body="true"
      :visible="curPopupsVisible"
      width="70%"
      @close="closeEdit"
      @open="open"
    >
      <dialogHeader
        slot="title"
        :title="'领用备件明细'"
        :style-type="$store.state.app.dialogType"
      ></dialogHeader>
      <one-table-template
        ref="multipleTable"
        :dynamic-buttons="tableButtons"
        :dynamic-components="tableComponents"
        :dynamic-api-config="dynamicApiConfigs"
        :dynamic-table-cols="tableCols"
        :dynamic-table-defult-height="400"
        :dynamic-form-fields="formField"
        :dynamic-is-show-select="false"
        :dynamic-is-init-table="true"
        :dynamic-is-fix-choose="false"
        :dynamic-is-fix-index="false"
        :is-show-pagination="false"
        :dynamic-api-style="'restful'"
      />
    </el-dialog>
  </section>
</template>
<script>
import { formMixins } from '@/components/mixins/formMixins'
import OneTableTemplate from '@/components/templates/oneTable'
import { orgApis } from '@/api/paSparePartsManagement'

export default {
  components: {
    OneTableTemplate,
    dialogHeader: () => import('@/components/dialogHeader'),
    mixButton: () => import('@/components/basicComponent/mixButton')
  },

  // 组件混入对象
  mixins: [formMixins],

  props: {
    editRowData: { type: Object, default: false },
    popupsVisible: { type: Boolean, default: false },
    // 从网格传入的编辑行数据(json)
    dynamicEditRowData: {
      type: Object,
      default: function() {
        return {}
      }
    }
  },

  data() {
    const viewPageCode = 'bigAreaInfo-edit'
    return {
      dynamicApiConfigs: orgApis.detail,
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
            {
              prop: 'partNo',
              label: '备件编码',
              align: 'center'
            },
            {
              prop: 'partName',
              label: '备件名称',
              align: 'center'
            },
            {
              prop: 'number',
              label: '库存数量',
              align: 'center'
            },
            {
              prop: 'qty',
              label: '领用数量',
              align: 'center'
            }
          ],

      // 表单数据（无需赋值，由混入对象赋值）
      formField: this.$utils.getFormField(
        this,
        {
          requisitionId: '',
          warehouseId: ''
        },
        this.$ConfigCache.CacheConfig.cacheData[viewPageCode]
      )
    }
  },

  methods: {
    open() {
      this.formField.requisitionId = this.dynamicEditRowData.requisitionId
      this.formField.warehouseId = this.dynamicEditRowData.warehouseId
      this.$refs['multipleTable'].queryTable()
    },
    // 关闭弹窗
    closeEdit() {
      this.$emit('update:popups-visible', false)
    }
  }
}
</script>

<style lang="scss" scoped>
// .promptSpan {
//   position: absolute;
//   bottom: 26px;
//   right: 335px;
//   color: #e70020;
// }
/deep/ .el-dialog__title {
  border-bottom: 0px !important;
}

</style>

